package Logic.GeneralManagerLogic;

import java.rmi.RemoteException;
import Po.Manager;
import RemoteServerInterface.GeneralManagerServerInterface;
import Start.GeneralManagerMain;
import VO.ManagerVO;

public class GeneralManagerLoginLogic {

	static GeneralManagerLoginLogic instance = new GeneralManagerLoginLogic();
	GeneralManagerServerInterface server = GeneralManagerMain.getManagerServer();
	Manager operator;

	public static GeneralManagerLoginLogic getInstance(){
		return instance;
	}
	
	private GeneralManagerLoginLogic(){
		super();
	}
	
	public GeneralManagerServerInterface getServer(){
		return server;
	}

	
	public boolean logout(){
		operator = null;
		return true;
	}
	
	public void setOperator(ManagerVO m){
		this.operator = m.toPO();
	}
	
	public boolean isLogin(){
		return operator!=null;
	}
	

	
	public boolean login(String name,String password) throws RemoteException{
		GeneralManagerServerInterface g = GeneralManagerMain.getManagerServer();
		Manager m = new Manager(name,password);
		Manager r = g.GeneralManagerLogin(m);
		if(r!=null){
			operator = r;
		}
		return operator!=null;
	}
}
